package middleware

import (
	"cashcenter/utils/resx"
	"github.com/gin-gonic/gin"
)

func ErrorMiddleware() gin.HandlerFunc {
	return func(ctx *gin.Context) {
		defer func() {
			err := recover()
			if err != nil {
				ctx.JSON(200, resx.GinResp(resx.SystemErr, err))
				ctx.Abort()
			}
		}()
		ctx.Next()
	}
}
